import request from '@/utils/request'

// base
const base = process.env.VUE_APP_BASE_API3 + '/olmList'
export function baseRequest(val) {
  return request({
    url: base + val.url,
    method: val.method,
    data: val.data
  })
}

// 新增
export function add(val) {
  return baseRequest({
    url: '/save',
    method: 'post',
    data: val
  })
}

// 更新
export function update(val) {
  return baseRequest({
    url: '/save',
    method: 'post',
    data: val
  })
}

// 删除
export function deleteById(val) {
  return baseRequest({
    url: '/deleteByIds',
    method: 'post',
    data: [val]
  })
}

// 批量删除
export function batchDelete(val) {
  return baseRequest({
    url: '/deleteByIds',
    method: 'post',
    data: val
  })
}

// 导入
export function upload(data) {
  return request({
    url: '/olm-excel/excel/importOlmListData',
    headers: { 'Content-Type': 'multipart/form-data' },
    method: 'put',
    timeout: 600000,
    data
  })
}

// 校验
export function validate(val) {
  return request({
    url: '/olm-api/olmList/submitValidate',
    method: 'post',
    timeout: 600000,
    data: val
  })
}

/** 获取门店信息 */
export function findUpcStoreInfoByListInfoId(id) {
  return request({
    url: process.env.VUE_APP_BASE_API3 + '/upc-store/findUpcStoreInfoByListInfoId/' + id,
    method: 'get',
    data: null
  })
}

// 提交
export function submit(val) {
  return request({
    url: '/olm-api/olmList/submit',
    method: 'post',
    timeout: 600000,
    data: val
  })
}

// 审核通过
export function approved(val) {
  return request({
    url: '/olm-api/olmList/approved',
    method: 'post',
    timeout: 600000,
    data: val
  })
}

// 审核驳回
export function reject(val) {
  return request({
    url: '/olm-api/olmList/reject',
    method: 'post',
    timeout: 600000,
    data: val
  })
}

// 终审档期
export function confirm(val) {
  return request({
    url: '/olm-api/olmList/confirm',
    method: 'post',
    timeout: 600000,
    data: val
  })
}
